package guiTesting;

import javax.swing.JFrame;
import javax.swing.JPanel;

import com.atlassian.crowd.exception.ApplicationPermissionException;
import com.atlassian.crowd.exception.GroupNotFoundException;
import com.atlassian.crowd.exception.InvalidAuthenticationException;
import com.atlassian.crowd.exception.InvalidGroupException;
import com.atlassian.crowd.exception.OperationFailedException;
import com.atlassian.crowd.exception.UserNotFoundException;
import com.atlassian.crowd.integration.rest.entity.GroupEntity;
import com.atlassian.crowd.integration.rest.service.factory.RestCrowdClientFactory;
import com.atlassian.crowd.model.group.Group;
import com.atlassian.crowd.model.group.GroupType;
import com.atlassian.crowd.service.client.CrowdClient;

public class AddGroup extends JPanel{
	String appLink = "https://code.bestbuy.com/crowd/";  //connection details 
	CrowdClient groupConn = new RestCrowdClientFactory().newInstance(appLink,"profile-mgt","1nitialPa55"); 

	public void AddGroup(Group grp) throws InvalidGroupException, ApplicationPermissionException, InvalidAuthenticationException, OperationFailedException{
		groupConn.addGroup(grp);


	}

	public Group createGroup(String grpName, String description, GroupType type, Boolean status){
		GroupEntity gp = new GroupEntity(grpName, description, type, status);
		return gp;

	}
	
	//this is during group creation when adding a developer group 
	public void addGroupToDeveloperGroup(String grp1) throws GroupNotFoundException, UserNotFoundException, OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException{
		
		String grp2 = "developer (Role)";
		groupConn.addGroupToGroup(grp1, grp2);
	}
	
	//add  business user group 
	public void addGroupToBusinessUserGroup(String grp1) throws GroupNotFoundException, UserNotFoundException, OperationFailedException, InvalidAuthenticationException, ApplicationPermissionException{
		String grp2 = "business-user (Role)";

		groupConn.addGroupToGroup(grp1, grp2);
	}
	
	public void removeGroup(String grpName) throws GroupNotFoundException, OperationFailedException, ApplicationPermissionException, InvalidAuthenticationException{
		groupConn.removeGroup(grpName);
		
	}

}
